﻿#include "hotelmanagecontent.h"
#include "ui_hotelmanagecontent.h"
#include <QMessageBox>

HotelManageContent::HotelManageContent(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::HotelManageContent)
{
    ui->setupUi(this);

    m_hotelID = GlobalVars::g_localHotel.getHotel();
    setWindowShow();
}

HotelManageContent::~HotelManageContent()
{
    delete ui;
}

const QString &HotelManageContent::getHotelID()
{
    return m_hotelID;
}

void HotelManageContent::setWindowShow()
{
    ui->lb_location->setText(GlobalVars::g_localHotel.getLocation());
    ui->lb_num->setText(GlobalVars::g_localHotel.getMark() + "分");
    ui->lb_type->setText(GlobalVars::g_localHotel.getType());
    ui->lb_hotelName->setText(GlobalVars::g_localHotel.getName());

    double mark = GlobalVars::g_localHotel.getMark().toDouble();
    if (mark == 5.0)
    {
        ui->lb_star->setText("★★★★★");
    }else if (mark >= 4)
    {
        ui->lb_star->setText("★★★★☆");
    }
    else if (mark >= 3)
    {
        ui->lb_star->setText("★★★☆☆");
    }else if (mark >= 2)
    {
        ui->lb_star->setText("★★☆☆☆");
    }else
    {
        ui->lb_star->setText("★☆☆☆☆");
    }
}

void HotelManageContent::setImage(const QImage& image)
{
    ui->lb_image->setPixmap(QPixmap::fromImage(image.scaled(120,100)));
}

void HotelManageContent::on_pb_watchHotelInfo_clicked()
{
    emit signalWatchHotelInfosDetails(m_hotelID);
}

void HotelManageContent::on_pb_watchHouseInfo_clicked()
{
    emit signalWatchHouseTypeInfos("0", m_hotelID);
}

void HotelManageContent::on_pb_deleteHotel_clicked()
{
    QMessageBox::StandardButton result = QMessageBox::warning(this,
                                 "警告",
                                 "确定要删除吗？",
                                 QMessageBox::Yes | QMessageBox::Cancel,
                                 QMessageBox::Cancel);

    if (result == QMessageBox::Yes)
    {
        emit signalDeleteHotelInfos(m_hotelID);
    }
}
